#define _CRT_SECURE_NO_WARNINGS 1

#include <string.h>
//int main()
//{
//    char chars[] = "aabbccc";
//    int maxl = 0;
//    int maxr = strlen(chars) - 1;
//    int l = 0;
//    int r = 0;
//    while (maxl <= maxr)
//    {
//            
//    }
//    for (int i = 0; chars[i]; ++i)
//    {
//
//    }
//    return 0;
//}
//
//void reverseStr(char* s)
//{
//	int len = strlen(s) - 1;
//	char tmp = *s;
//	*s = *(s + len);
//	*(s + len) = 0;
//	if (*(s + 1) != 0)
//	{
//		reverseStr(s + 1);
//	}
//	*(s + len) = tmp;
//}
//int main()
//{
//	char s[] = "barfoothefoobarman";
//	char* words[] = { "foo","bar" };
//	int wordsSize = sizeof(words) / sizeof(words[0]);
//
//	int sumLen = 0;
//	int everyWordslen = strlen(words[0]);
//	char arr1[10] = { 0 };
//	char arr2[10] = { 0 };
//
//	int ans[2] = { 0 };
//	int index = 0;
//	for (int i = 0; i < wordsSize; ++i)
//	{
//		sumLen += strlen(words[i]);
//		strcat(arr1, words[i]);
//		strcat(arr2, words[i]);
//	}
//	reverseStr(arr2);
//	for (int i = 0; i < strlen(s); i += everyWordslen)
//	{	
//		int f = 2;
//		for (int j = i, arrIndex = 0; j < sumLen; ++j, ++arrIndex)
//		{
//			if (arr1[arrIndex] != s[j] && f == 2)
//			{
//				--f;
//			}
//			if (arr2[arrIndex] != s[j] && f == 1)
//			{
//				--f;
//				break;
//			}
//		}
//		if (f)
//		{
//			ans[index++] = i;
//		}
//	}
//	return 0;
//}



#include <ctype.h>
int main()
{
	char paragraph[] = "Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. Bob hit a ball, the hit BALL flew far after it was hit. ";
	char* banned[4] = { "hit" };
	int f = 0;
	int s = 0;
	int flag = 0;
	while (f < strlen(paragraph))
	{
		if (isalpha(paragraph[f]))
		{
			flag = 1;
			if (isupper(paragraph[f]))
			{
				paragraph[s++] = tolower(paragraph[f]);
			}
			else
			{
				paragraph[s++] = paragraph[f];
			}
		}
		else if(flag == 1)
		{
			paragraph[s++] = ' ';
			++flag;
		}
		++f;
	}
	paragraph[s] = 0;
	f = 0;
	char arr[100][100] = { 0 };
	int row = 0;
	int col = 0;
	while (f < strlen(paragraph))
	{
		if (isalpha(paragraph[f]))
		{
			if (isupper(paragraph[f]))
			{
				arr[row][col++] = tolower(paragraph[f]);
			}
			else
			{
				arr[row][col++] = paragraph[f];
			}
		}
		else if(paragraph[f] == ' ')
		{
			for (int i = 0; i < 1; ++i)
			{
				if (strcmp(arr[row], banned[i]) == 0)
				{
					for (int j = 0; j < col; ++j)
					{
						arr[row][j] = 0;
					}
					--row;
					break;
				}
			}							    
			++row;
			col = 0;
		}
		++f;
	} 
	int ans = 0;
	int ans1 = row;
	for (int i = 0; i < row; ++i)
	{
		int sum = 0;
		for (int j = i; j < row; ++j)
		{
			if (strcmp(arr[i], arr[j]) == 0)
				++sum;
		}
		if (sum > ans)
		{
			ans = sum;
			strcpy(arr[ans1], arr[i]);
		}
	}
	strcpy(paragraph, arr[ans1]);
	return 0;
}

//
//void my_strcpy(char* dest, char* src)
//{
//	char* start = dest + strlen(dest);
//	while (*start++ = *src++);
//}
//int main()
//{
//	char s[20] = "abcd1";
//	my_strcpy(s, s);
//	return 0;
//}